// ConfigAdapter.h
#ifndef CONFIGADAPTER_H
#define CONFIGADAPTER_H

#include <QObject>
#include <QVariantMap>
#include <QString>
#include <mutex>
#include "configmanager.h"
#include "logger.h" // 包含日志系统头文件

class ConfigAdapter : public QObject {
    Q_OBJECT

public:

    explicit ConfigAdapter(QObject* parent = nullptr);

    Q_INVOKABLE void loadConfigTable(const QString& configTableFile);
    Q_INVOKABLE void loadOrCreateValueTable(const QString& valueTableFile);
    Q_INVOKABLE void saveValueTable(const QString& valueTableFile);

    Q_INVOKABLE QVariantMap getAllParameters() const;
    Q_INVOKABLE QVariantMap getSectionParameters(const QString& section) const;
    Q_INVOKABLE QVariant getParameter(const QString& section, const QString& key) const;
    Q_INVOKABLE QVariantMap getConfig(const QString& section, const QString& key) const;
    Q_INVOKABLE void setParameter(const QString& section, const QString& key, const QVariant& value);

private:
    mutable std::mutex mutex_;
};

#endif // CONFIGADAPTER_H
